﻿<?php
	defined('_JEXEC') or die(); 
	JHTML::_('behavior.tooltip');
	$db = JFactory::getDbo();
	$baseon = empty($this->baseon)?1:$this->baseon;
?>
<style>
    #tbl_filter{
        margin: 0 ; padding: 0 ;
    }
    #tbl_filter td{
        padding: 3px;
    }
    #tbl_filter input, #tbl_filter img {
        float: left;
        margin: 0 5px 0 0;
        width: auto;
    }
    #extra_filter_field { width: 114px; }
    table.adminlist tbody tr td { padding: 8px 8px; }
    table.adminlist thead th { padding: 8px; }
</style>
<link rel="stylesheet" type="text/css" href="<?php echo JURI::root(); ?>js/multiselect/jquery.multiselect.css" />
<link rel="stylesheet" type="text/css" href="<?php echo JURI::root(); ?>js/multiselect/jquery-ui.css" />
<script type="text/javascript" src="<?php echo JURI::root(); ?>js/jquery.js"></script>
<script type="text/javascript" src="<?php echo JURI::root(); ?>js/jquery-ui.min.js"></script>
<script type="text/javascript" src="<?php echo JURI::root(); ?>js/multiselect/jquery.multiselect.js"></script>
<script>
jQuery(function(){
	var topDisplay = <?php echo empty($this->topDisplay)?20:$this->topDisplay;?>;
	jQuery("#topDisplaySelect").val(topDisplay);
	
	var baseon = <?php echo empty($this->baseon)?1:$this->baseon;?>;
	jQuery("#baseon").val(baseon);
});

</script>
<div class="row-fluid">
    <?php if (!empty( $this->sidebar)) : ?>
	<div id="j-sidebar-container" class="span2">
		<?php echo $this->sidebar; ?>
	</div>
	<div id="j-main-container" class="span10">
	<?php else : ?>
		<div id="j-main-container">
	<?php endif;?>
		<br clear="all">	
    	<div class="alert">
             <form action="<?php echo JRoute::_("index.php?option=com_wrd&controller=reports")?>" method="post" name="filterform" >
                <table style='margin-bottom:5px' id="tbl_filter">
                    <tbody>
                        <tr>
                            <td align="left" valign="top" style="">
                                <table >
                                    <tr>
                                        <td>Business Date From<br>
                                           <?php
                                              echo JHTML::_ ( 'calendar', $this->pr['date_from'], 'date_from', 'date_from', '%Y-%m-%d');
											?>
                                        </td>
                                        <td>Business Date To <br>
                                            <?php
                                                
												echo JHTML::_ ( 'calendar', $this->pr['date_to'], 'date_to', 'date_to', '%Y-%m-%d');
											?>
                                        </td>  
                                        <td>Base On: <br>
                                          <select class="baseon" name="baseon" id="baseon">
                                                <option value="1">Actual Paid</option>
												<option value="2">Net Sale</option>
                                                <option value="3">Visited times</option>
                                            </select>
                                        </td>
										<td><input onclick="document.getElementById('task').value = '';" type="submit" name="view" value="View" /></td>
                                   </tr>
                                   <tr>
										<td>
										Choose: <br>
                                           <select class="topDisplay" name="topDisplaySelect" id="topDisplaySelect">
                                                <option value="5">5</option>
												<option value="10">10</option>
												<option value="15">15</option>
												<option value="20">20</option>
												<option value="20">25</option>
                                                <option value="30">30</option>
                                                <option value="50">50</option>
                                                <option value="100">100</option>
												<option value="200">200</option>
												<option value="400">400</option>
												<option value="800">800</option>
                                                <option value="0">All</option>
                                            </select>
											
                                        </td>
										<td colspan="6">
											<input type="submit" name="exportexcel" onclick="document.getElementById('task').value = 'exoutletreport';" value="Export to excel" />
										</td>
										<td>
										</td>
									</tr>
                                </table>                                
                            </td>                             
                           
                    </tr>

						
                </table>
<input type="hidden" name="controller" value="reports" />
<input type="hidden" name="option" value="com_wrd" />
<input type="hidden" name="layout" value="outletreport" />
<input type="hidden" name="task" id="task" value="" />
</form> 
</div>
<br clear="all">   
<form id="adminForm" action="<?php echo JRoute::_("index.php?option=com_wrd")?>" method="post" name="adminForm" >			
<style>
.extra-adminlist strong { color:#025A8D; font-size: 1.2em; font-weight: bold; }
table.extra-adminlist .extra-adminlist-tr td {background: #F7F7F7; }
.filter-detail { border-top: 1px solid #CCC; padding-bottom: 3px; font-size: 1.4em; }
.filter-detail span { color: #e72222; }
</style>
<h3 class="filter-detail"><br/><span style="color:#C00; float:right;">Total: <?php echo $this->pagination->total; ?></span></h3>
<table class="adminlist extra-adminlist table">
<thead>
<tr>
<th width="3%">Order</th>
<th nowrap="nowrap">Member ID</th>        
<th nowrap="nowrap">Amigo</th>
<th nowrap="nowrap">Kissho</th>
<th nowrap="nowrap">CCAD</th>
<th nowrap="nowrap">CCNH</th>
<th nowrap="nowrap">Ngân Đình</th>
<th nowrap="nowrap">TOTT</th>
<th nowrap="nowrap">Đức Bảo</th>
<th nowrap="nowrap">Spa & Massage</th>
<th nowrap="nowrap">AD Food Court</th>
<th nowrap="nowrap">The Club</th>
<th nowrap="nowrap">America</th>
<th nowrap="nowrap">Total</th>
</tr>
</thead>
<tbody>
<?php 

$dateFrom = $this->pr['date_from']." 00:00:00";
$dateTo   = $this->pr['date_to']." 23:59:59";	

if(!empty($this->items)):
	$index = 0;
	$i=1;
	foreach($this->items as $key => $item):
	   $bg = $i%2;
		echo '<tr style="cursor: pointer;" class="row'.($bg).'" valign="top">';
			echo '<td>'.$i.'</td>';
			echo '<td>'.$item->vip_number.'</td>';
			echo '<td>'.number_format(reportProvider::getTotal($db,$item->vip_number,$outlet=111,$dateFrom,$dateTo,$baseon),0,".",",").'</td>';				
			echo '<td>'.number_format(reportProvider::getTotal($db,$item->vip_number,$outlet=181,$dateFrom,$dateTo,$baseon),0,".",",").'</td>'; 
			echo '<td>'.number_format(reportProvider::getTotal($db,$item->vip_number,$outlet=221,$dateFrom,$dateTo,$baseon),0,".",",").'</td>'; 
			echo '<td>'.number_format(reportProvider::getTotal($db,$item->vip_number,$outlet=131,$dateFrom,$dateTo,$baseon),0,".",",").'</td>'; 
			echo '<td>'.number_format(reportProvider::getTotal($db,$item->vip_number,$outlet=211,$dateFrom,$dateTo,$baseon),0,".",",").'</td>'; 
			echo '<td>'.number_format(reportProvider::getTotal($db,$item->vip_number,$outlet=191,$dateFrom,$dateTo,$baseon),0,".",",").'</td>';
			echo '<td>'.number_format(reportProvider::getTotal($db,$item->vip_number,$outlet=121,$dateFrom,$dateTo,$baseon),0,".",",").'</td>';
			echo '<td>'.number_format(reportProvider::getTotal($db,$item->vip_number,$outlet=22,$dateFrom,$dateTo,$baseon),0,".",",").'</td>';
			echo '<td>'.number_format(reportProvider::getTotal($db,$item->vip_number,$outlet=234,$dateFrom,$dateTo,$baseon),0,".",",").'</td>';
			echo '<td>'.number_format(reportProvider::getTotal($db,$item->vip_number,$outlet=141,$dateFrom,$dateTo,$baseon),0,".",",").'</td>';
			echo '<td>'.number_format(reportProvider::getTotal($db,$item->vip_number,$outlet=201,$dateFrom,$dateTo,$baseon),0,".",",").'</td>';
			$total = reportProvider::getTotal($db,$item->vip_number,$outlet=111,$dateFrom,$dateTo,$baseon)
				   + reportProvider::getTotal($db,$item->vip_number,$outlet=181,$dateFrom,$dateTo,$baseon)
				   + reportProvider::getTotal($db,$item->vip_number,$outlet=221,$dateFrom,$dateTo,$baseon)
				   + reportProvider::getTotal($db,$item->vip_number,$outlet=131,$dateFrom,$dateTo,$baseon)
				   + reportProvider::getTotal($db,$item->vip_number,$outlet=211,$dateFrom,$dateTo,$baseon)
				   + reportProvider::getTotal($db,$item->vip_number,$outlet=191,$dateFrom,$dateTo,$baseon)
				   + reportProvider::getTotal($db,$item->vip_number,$outlet=201,$dateFrom,$dateTo,$baseon)
				   + reportProvider::getTotal($db,$item->vip_number,$outlet=234,$dateFrom,$dateTo,$baseon)
				   + reportProvider::getTotal($db,$item->vip_number,$outlet=121,$dateFrom,$dateTo,$baseon)
				   + reportProvider::getTotal($db,$item->vip_number,$outlet=141,$dateFrom,$dateTo,$baseon)
				   + reportProvider::getTotal($db,$item->vip_number,$outlet=22,$dateFrom,$dateTo,$baseon);
				   
			echo '<td>'.number_format($total,0,".",",").'</td>';
		echo '</tr>';
	   $i++;
	endforeach;
endif;
?>
</tbody>
  <tfoot>
        <tr>
            <td colspan="16">
                <?php echo $this->pagination->getListFooter(); ?>
            </td>
        </tr>
    </tfoot>
</table>
<input type="hidden" name="controller" value="reports" />
<input type="hidden" name="option" value="com_wrd" />
<input type="hidden" name="topDisplaySelect" id="topDisplay" value="" />
<input name="status" type="hidden" class="status" value="" />
<input type="hidden" name="baseon" value="<?php echo $baseon;?>" />
<input type="hidden" name="layout" value="outletreport" />
<input type="hidden" name="boxchecked" value="0" />
	<?php echo JHTML::_( 'form.token' ); ?>
</form>
</div>
        
</div>
